import moment from 'moment'
import _data from './_data.js'
import _mixins from '@/common/_mixins.js'
import {
	pathToBase64
} from '@/plugins/image-tools/index.js'
import permision from "@/plugins/js_sdk/wa-permission/permission.js"

function getGlobalData(name) {
	try {
		return _data.data(name)
	} catch(err) {
		return _data[name]
	}
}

function getImgVersion() {
	return '?v=' + getGlobalData('version')
}

export function getRandom() {
	let t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	let len = t.length;
	let id = '';
	for (let i = 0; i < 32; i++) {
		id += t.charAt(Math.floor(Math.random() * len))
	}
	return id;
}

/**
 * 判断是否为ios
 */
export function is_iOS() {
	return uni.getSystemInfoSync().platform == 'ios'
}

/**
 * 获取tableSuffixt
 */
export function getTableSuffix() {
	let len = arguments.length;
	if (len == 0) {
		let year = (moment().year() + '').substr(2)
		let month = moment().month() + 1
		month = month < 10 ? '0' + month : month
		let tablesuffix = _data.localData('obscode') + "_" + year + month
		return tablesuffix
	} else if (len == 1) {
		let date = arguments[0];
		let year = (moment(date).year() + '').substr(2)
		let month = moment(date).month() + 1
		month = month < 10 ? '0' + month : month
		let tablesuffix = _data.localData('obscode') + "_" + year + month
		return tablesuffix
	} else if (len == 2) {
		let year = arguments[0];
		let month = arguments[1];
		year = (year + '').substr(2)
		let tablesuffix = _data.localData('obscode') + "_" + year + month
		return tablesuffix
	}
}

/**输出图片网络地址
 * @param {Object} v
 */
export function formatImg(v, flag = true) {
	let t1 = v.replace(/(\/)?homepage/g, getGlobalData('static_img') + '/homepage');
	let t2 = t1.replace(/\\/g, '/');
	return flag ? t2 + getImgVersion() : t2
}

/**
 * 删除图片http地址
 * @param {Object} v
 */
export function imageStrigify(v) {
	const regExp = new RegExp(getGlobalData('static_img'), 'g');
	let str = typeof v == 'string' ? v.replace(regExp, '') : '';
	return str
}

/**图片数组对象转string
 * @param {Object} v
 */
export function imageArrayToString(list,propertyList) {
	let temp = [];
	for (let i = 0; i < list.length; i++) {
		let item = list[i];
		if(propertyList && propertyList.length) {
			let keys = Object.keys(item)
			let values = [];
			for (let j = 0; j < propertyList.length; j++) {
				let flag = false;
				for (let x = 0; x < keys.length; x++) {
					if(propertyList[j] == keys[x]) flag = true;
				}
				
				if(flag) values.push(item[propertyList[j]])
			}
			let itemString = values.join(',')
			temp.push(itemString)
		} else {
			let values = Object.values(item)
			let itemString = values.join(',')
			temp.push(itemString)
		}
	}
	return temp.join('|')
}

/**图片string转数组对象
 * @param {Object} v
 */
export function imageStringToArray(string,propertyList) {
	if(!string) return []
	let list = string.split('|');
	let temp = [];
	for (let i = 0; i < list.length; i++) {
		let item = list[i].split(',');
		let obj = {};
		for (let j = 0; j < item.length; j++) {
			if(!propertyList || propertyList.length <= j) {
				obj[j] = item[j];
			} else {
				obj[propertyList[j]] = item[j];
			}
		}
		temp.push(obj)
	}
	return temp
}

/**
 * 格式化时间为文字描述
 * @param {Object} v
 */
export function formatTime(v) {
	v = v * 1;
	let hour = v / 60;
	if (hour < 1) {
		return v + '分钟'
	} else if (1 <= hour && hour < 24) {
		let min = v % 60;
		if (min == 0) {
			return Math.floor(hour) + '小时';
		}
		return Math.floor(hour) + '小时' + min + '分钟';
	} else {
		let day = hour / 24;
		let h = hour % 24;
		let m = v % 60;
		if (h == 0 && m == 0) {
			return Math.floor(day) + '天'
		} else if (m == 0) {
			return Math.floor(day) + '天' + Math.floor(h) + '小时'
		} else {
			return Math.floor(day) + '天' + Math.floor(h) + '小时' + m + '分钟'
		}
	}
}

/** 时间戳转换 */
export function timestampFormat(timestamp) {
	timestamp = moment(timestamp).format('X')*1;
	let curTimestamp = parseInt(new Date().getTime() / 1000), //当前时间戳
		timestampDiff = curTimestamp - timestamp, // 参数时间戳与当前时间戳相差秒数
		curDate = new Date(curTimestamp * 1000), // 当前时间日期对象
		tmDate = new Date(timestamp * 1000), // 参数时间戳转换成的日期对象
		Y = tmDate.getFullYear(),
		m = tmDate.getMonth() + 1,
		d = tmDate.getDate(),
		H = tmDate.getHours(),
		i = tmDate.getMinutes(),
		s = tmDate.getSeconds();
	if (timestampDiff < 60) { // 一分钟以内
		return "刚刚";
	} else if (timestampDiff < 60 * 60) { // 一小时前之内
		return Math.floor(timestampDiff / 60) + "分钟前";
	} else if (timestampDiff < 60 * 60 * 24) { //今天之内
		return Math.floor(timestampDiff / 60 / 60) + '小时前';
	} else {
		if (curDate.getFullYear() == Y) {
			return ((String(m).length == 1 ? '0' : '') + m) + '-' + ((String(d).length == 1 ? '0' : '') + d);
		} else {
			return Y + '-' + ((String(m).length == 1 ? '0' : '') + m) + '-' + ((String(d).length == 1 ? '0' : '') + d);
		}
	}
}

/** 未来时间戳转换 */
export function futureTimestampFormat(timestamp) {
	timestamp = moment(timestamp).format('X')*1;
	let curTimestamp = parseInt(new Date().getTime() / 1000), //当前时间戳
		timestampDiff = timestamp - curTimestamp, // 参数时间戳与当前时间戳相差秒数
		curDate = new Date(curTimestamp * 1000), // 当前时间日期对象
		tmDate = new Date(timestamp * 1000), // 参数时间戳转换成的日期对象
		Y = tmDate.getFullYear(),
		m = tmDate.getMonth() + 1 < 10 ? '0' + (tmDate.getMonth() + 1)  : tmDate.getMonth() + 1,
		d = tmDate.getDate() < 10 ? '0' + tmDate.getDate() : tmDate.getDate(),
		H = tmDate.getHours() < 10 ? '0' + tmDate.getHours() : tmDate.getHours(),
		i = tmDate.getMinutes() < 10 ? '0' + tmDate.getMinutes() : tmDate.getMinutes(),
		s = tmDate.getSeconds();
	if(timestampDiff < 0) return true
	if(timestampDiff < 60 * 60 * 24) {
		return H + ':' + i
	} else if(timestampDiff < 60 * 60 * 24 * 2) {
		return '明天' +  H + ':' + i
	} else if(timestampDiff < 60 * 60 * 24 * 3) {
		return '后天' +  H + ':' + i
	} else {
		return m + '-' + d + ' ' + H + ':' + i
	}
}

/**输出转换后的图片数组
 * @param {Object} v 为转化的图片数组
 */
export function formatImgList(v) {
	let t1 = v.replace(/homepage/g, _data.data('static_img') + '/homepage');
	let t2 = t1.replace(/\\/g, '/');
	let arr = t2.split(',')
	arr.forEach(item => {
		item = item + getImgVersion()
	})
	return arr
}

/**
 * 一维数组转树型结构
 * @param {Object} data 数组
 * @param {Object} id 元素的id
 * @param {Object} parentId 元素父级的id
 * @param {Object} firstPid 根节点的id
 */
export function arrayToTree(data, id, parentId, firstPid) {
	const idMapping = data.reduce((obj, el, i) => {
		obj[el[id]] = i;
		return obj;
	}, {});
	let root;
	data.forEach(el => {
		// 判断根节点
		if (el[parentId] == firstPid) {
			root = el;
			return;
		}
		// 用映射表找到父元素
		const parentEl = data[idMapping[el[parentId]]];
		// 把当前元素添加到父元素的`children`数组中
		parentEl.children = [...(parentEl.children || []), el];
	})
	return [root]
}

/**
 * 获取当年第几周(以第一周周一为准)
 */
export function getWeekInYear1(date) {
	let currentWeekFrist = moment(date).startOf('isoweek').format('YYYY-MM-DD'); //当前日期的周一日期
	let firstDay = moment(currentWeekFrist).year() + '-01-01'; //当前年份的第一天
	var weekDay = new Date(firstDay).getDay(); //获取周中的某一天
	if (weekDay == 1) {
		weekDay = 0
	} else if (weekDay == 0) {
		weekDay = 1
	} else {
		weekDay = 8 - weekDay
	}
	var weekFirst = moment(firstDay).add(weekDay, 'days').format('YYYY-MM-DD'); //获取一年中第一周周一的日期
	var diff = moment(date).diff(weekFirst, 'day') + 1; //两个日期相差天数
	let week = Math.ceil(diff / 7); //获取第几周
	return week == 0 ? 1 : week; //如果为0是第一周
}

/**
 * 获取当年第几周(以1月1号为准,只有1月1号刚好为周一时才会有第一周)
 */
export function getWeekInYear2(date) {
	let currentWeekFrist = moment(date).startOf('isoweek').format('YYYY-MM-DD'); //当前日期的周一日期
	let firstDay = moment(currentWeekFrist).year() + '-01-01'; //当前年份的第一天
	var weekDay = new Date(firstDay).getDay(); //获取周中的某一天
	if (weekDay == 1) {
		weekDay = 0
	} else if (weekDay == 0) {
		weekDay = 7
	} else {
		weekDay = weekDay
	}
	var diff = moment(currentWeekFrist).diff(firstDay, 'day') + 1 + weekDay; //两个日期相差天数
	let week = Math.ceil(diff / 7); //获取第几周
	return week; //如果为0是第一周
}

/**
 * 根据周数获取起止日期
 */
export function getDateFromWeek(year, week) {
	let firstDay = year + '-01-01'; //当前年份的第一天
	var weekDay = new Date(firstDay).getDay(); //获取周中的某一天
	let diff = (week * 1 - 1) * 7;
	let date = moment(firstDay).add(diff, 'days');
	let startDate = moment(date).startOf('isoWeek').format('YYYY-MM-DD')
	let endDate = moment(date).endOf('isoWeek').format('YYYY-MM-DD')
	return [startDate, endDate]
}

/**
 * 向上一个或多个页面传递函数和数据
 * @param {Object} n 返回页面的方法名
 * @param {Object} v 参数
 */
export function sendBackFunction(n, v ,delta=1) {
	var pages = getCurrentPages();
	var prevPage = pages[pages.length - 2 - (delta - 1)]; //上一个页面
	prevPage.$vm[n](v); //重点$vm
	setTimeout(() => {
		uni.navigateBack({
			delta: delta
		})
	},300)
}

/**
 * 设置小数位数（如果有小数保留两位，如果没有则直接返回）
 * @param {Object} v  待处理数字
 * @param {Object} v  保留位数
 */
export function setDotNumber(v, n = 2, isFormat = false) {
	let value = v * 1;
	var index = (value + '').indexOf('.'); //小数点的位置
	if (index > 0) {
		let num = value.toFixed(n) * 1;
		return isFormat ? parseFloat(num).toLocaleString() : num;
	} else {
		return isFormat ? parseFloat(value).toLocaleString() : value;
	}
}

/**
 * 节流(一定的时间内只会触发一次函数)
 * @param {Object} fn	待执行函数
 * @param {Object} delay	延迟时间
 */
export function throttle(fn, delay) {
	let timer = null

	//返回一个函数出去  这个函数可以接收参数来执行你的下一步操作
	return function() {

		//保存this对象
		let _this = this
		//传入的参数
		let arg = arguments

		if (timer) {
			return
		} else {
			//触发节流函数
			timer = setTimeout(() => {
				//延迟结束 重置timer 清除延时器
				timer = null
				//执行你想要的操作
				fn.apply(_this, arg)
			}, delay)
		}
	}
}

/**
 * 防抖(规定时间后才能执行下一次函数)
 * @param {Object} fn	待执行函数
 * @param {Object} delay	延迟时间
 */
export function debounce(fn, delay) {
	let timer = null

	//返回一个函数出去  这个函数可以接收参数来执行你的下一步操作
	return function() {

		//保存this对象
		let _this = this
		//传入的参数
		let arg = arguments

		//清除延时器
		clearTimeout(timer);
		//设置一个延时器 延时结束进行操作
		timer = setTimeout(() => {
			//执行你想要的操作
			fn.apply(_this, arg)
		}, delay)

	}
}

/**
 * 判断android授权，1：已授权，0：未授权，-1：永久拒绝授权
 * @param {Object} permisionID Android权限名称
 */
async function requestAndroidPermission(permisionID, text) {
	var result = await permision.requestAndroidPermission(permisionID)
	var strStatus
	if (result == 1) {
		strStatus = "已获得授权"
	} else if (result == 0) {
		strStatus = "未获得授权"
	} else {
		strStatus = text + "权限被永久拒绝"
		uni.showToast({
			title: strStatus,
			icon: 'none'
		})
	}
	return result
}

/**
 * 判断安卓/ios权限并设置
 * @param {Object} iosPermissionId	ios权限名称
 * @param {Object} androidPermissionId	android权限名称id
 * @param {Object} text	android权限名称
 */
export function settingPermission(iosPermissionId, androidPermissionId, text) {
	let platform = uni.getSystemInfoSync().platform;
	if (platform == 'android') {
		let androidPermission = requestAndroidPermission(androidPermissionId, text)
		if (androidPermission == 0) permision.gotoAppPermissionSetting();
	}
}

/**
 * 评论的图片还原地址
 * @param {Object} v
 */
export function imgStrigify(v) {
	try {
		let url1 = new RegExp(('src="' + _data.static_img + '/homepage'), "g");
		let url2 = 'src="/homepage'
		return v.replace(url1, url2)
	} catch (e) {
		console.log(e)
	}
}

/**
 * 评论的图片替换地址
 * @param {Object} v
 */
export function imgParse(v) {
	try {
		let url1 = /(src="\/homepage)/g
		let url2 = 'src="' + _data.data('static_img') + '/homepage'
		let str = typeof v == 'string' ? v.replace(url1, url2) : ''
		return str
	} catch (e) {
		console.log(e)
	}
}

/**
 * 表情转码(emoji为utf-16转成utf-8)
 * @param {Object} str
 */
export function utf16toEntities(str) {
	try {
		var patt=/([0-9|*|#]\uFE0F\u20E3)|([0-9|#]\u20E3)|([\u203C-\u3299]\uFE0F\u200D)|([\u203C-\u3299]\uFE0F)|([\u2122-\u2B55])|(\u303D)|([\A9|\AE]\u3030)|(\uA9)|(\uAE)|(\u3030)|([\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF])|([\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F])|[\u200D]|[\uFE0F]/g; // 检测utf16字符正则   
		str = str.replace(patt, function(char){
			return "&#" + char.codePointAt(0) + ";";
		});
		return str;
	} catch(e) {
		return str;
	}
}

/**
 * 表情解码(utf-8转成utf-16)
 * @param {Object} str
 */
export function entitiestoUtf16(str) {
	try {
		var reg = /\&#.*?;/g;
	　　var result = str.replace(reg,function(char){
			let res = char.match(/[1-9]\d*/g);
			return String.fromCodePoint(res);
		});
	　　return result;
	} catch(e) {
		return str;
	}
}

/**
 * 图片缓存（非renderjs环境）
 * @param {Object} image_url  图片网络地址
 * @param {Object} image_name  图片本地缓存的名称
 * @param {Object} call_back  回调函数
 */
export function image_cache(image_url, image_name, call_back) {
	uni.getStorage({
		key: image_name,
		success: function(res) {
			call_back(res.data)
		},
		fail: function(res) {
			// 本地没有缓存 需要下载
			uni.downloadFile({
				url: image_url,
				success: (res) => {
					if (res.statusCode === 200) {
						call_back(res.data)
						uni.setStorage({
							key: image_name,
							data: res,
						})
					}
				}
			});
		}
	})
}

/**
 * 原生接口下载文件
 * @param {Object} name
 * @param {Object} url
 * @param {Object} callback
 */
function download_file(name, url, callback) {
	var dtask = plus.downloader.createDownload(url, {
		filename: '_doc/' + name //利用保存路径，实现下载文件的重命名
	}, function(d, status) {
		//d为下载的文件对象
		if (status == 200) {
			//下载成功,d.filename是文件在保存在本地的相对路径，使用下面的API可转为平台绝对路径
			var fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
			callback({
				relativeFilepath: d.filename, //相对路径
				absoluteFilepath: fileSaveUrl, //绝对路径
				isFile: true
			})
		} else {
			console.log(status)
			//下载失败
			plus.downloader.clear(); //清除下载任务
			callback({
				relativeFilepath: '',
				absoluteFilepath: '',
				isFile: false
			})
		}
	})
	dtask.start();
}

/**
 * 图片缓存（renderjs、app环境）
 * @param {Object} image_url  图片网络地址
 * @param {Object} image_name  图片本地缓存的名称
 * @param {Object} callback  回调函数
 */
export function js_image_cache(image_url, image_name, callback) {
	let filePath = plus.storage.getItem(image_name);
	plus.io.resolveLocalFileSystemURL(filePath,
		res => {
			try {
				callback(filePath);
			} catch(e) {console.log(e)}
		},
		err =>  {
			plus.storage.removeItem(image_name);
			download_file(image_name,image_url,res => {
				if(res.isFile) {
					plus.storage.setItem(image_name, res.absoluteFilepath);
					callback(res.absoluteFilepath);
				} else {
					callback(image_url);
				}
			})
		}
	);

}

/**图片上传
 * @param {Object} obj uni.chooseImage参数 + fileName属性(后台保存的文件名称)
 * @param {Object} fn 回调函数,返回对象（path：带homepage地址，extension：后缀名，img：网络地址，只做展示用，上传还是用path参数）
 */
export function uploadImages(obj, fn, fnError) {
	if (!obj.sourceType) {
		obj.sourceType = ['album', 'camera'];
	}
	if (!obj.sizeType) {
		obj.sizeType = ['compressed'];
	}
	// #ifdef APP-PLUS
	if (obj.sourceType.length) {
		obj.sourceType.forEach(item => {
			if (item == 'album') {
				settingPermission("photoLibrary", "android.permission.READ_EXTERNAL_STORAGE", "相册")
			} else if (item == 'camera') {
				settingPermission("camera", "android.permission.CAMERA", "摄像头")
			}
		})
	}
	// #endif
	uni.chooseImage({
		...obj,
		success: (res) => {
			let type = '';
			if (res.tempFiles.length) {
				let index = res.tempFiles[0].path.indexOf('file:');
				type = index == -1 ? 'camera' : 'album';
			}
			uni.showLoading({
				title: '上传中...'
			})
			let p = res.tempFiles.map(v => {
				return pathToBase64(v.path)
			})
			for (let i = 0; i < res.tempFilePaths.length; i++) {
				uni.getImageInfo({
					src: res.tempFilePaths[i],
					success: image => {
						res.tempFiles[i].width = image.width;
						res.tempFiles[i].height = image.height;
					}
				});
			}
			Promise.all(p).then(resultes => {
				let ps = resultes.map((item, index) => {
					return new Promise((resolve, reject) => {
						setTimeout(() => {
							uni.request({
								url: _data.data('http_upload_url'),
								data: {
									"code": obj.code ? obj.code : 1001,
									"token": _data.localData(
										'obs_token'),
									"APIname": obj.fileName ? obj
										.fileName : 'WUNIIMG',
									"WaterMarkParam": [{}],
									"imgdata": item,
									"compress": 70
								},
								method: 'POST',
								dataType: 'json',
								success(value) {
									if (value.data.msgcode == 0) {
										let dir = value.data.dir.replace(/\\/g,'/');
										let path = dir +
											value.data.filename;
										let img = formatImg(path,
											false)
										let extension = '.' + value
											.data.filename
											.split('.').pop()
											.toLowerCase();
										resolve({
											img,
											path,
											extension,
											type,
											width: res
												.tempFiles[
													index]
												.width,
											height: res
												.tempFiles[
													index]
												.height
										})
									} else {
										reject()
									}
								},
								fail() {
									reject()
								}
							})
						}, index * 500)
					})
				})
				Promise.all(ps).then(r => {
					uni.hideLoading()
					if (fn) {
						fn(r)
					}
				}).catch(e => {
					uni.hideLoading()
					if (fnError) {
						fnError(e)
					}
				})
			})
		},
	})
}

/**
 * 扫描二维码
 */
export function goScanCode() {
	let _this = this;
	uni.scanCode({
		success: function(res) {
			let code = [''];
			try {
				code = res.result.split('-')
			} catch (e) {}
			/** 验证必须是一个地址 */
			if (/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/.test(res
					.result)) {
				/** 本应用页面 */
				if (new RegExp(_data.data('http_url')).test(res.result)) {
					let type = getQueryString(res.result, 'type');
					switch (type) {
						case 'chat_add':
							let user_id = getQueryString(res.result, 'user_id');
							uni.navigateTo({
								url: '/pages/details/index?user_id=' + user_id + '&is_type=3',
							});
							break;
						case 'group_add':
							let users = getQueryString(res.result, 'inviter_id');
							let list_id = getQueryString(res.result, 'list_id');
							_mixins.methods.$httpSend({
								path: '/im/message/addChat',
								data: {
									users: users,
									list_id: list_id,
									type: 1,
								},
								success_action: true,
								success(res) {
									let tips = res.err ? res.msg : '已经申请加入群聊,请耐心等待群管理审核';
									uni.showModal({
										content: tips,
										showCancel: false,
									});
								}
							});
							break;
						default:
							uni.showModal({
								content: '二维码内容：' + res.result,
								showCancel: false,
							});
							break;
					}
				} else {
					/** 打开新地址 */
					uni.navigateTo({
						url: '/pages/push/web?url=' + encodeURIComponent(res.result),
					});
				}
			} else if (code[0] == 'SB') {
				if (code[1] != _data.localData('obscode')) {
					uni.showModal({
						content: '请切换到对应水厂扫码'
					})
				} else {
					let data = {
						obscode: code[1],
						device: code[2],
						devicecode: code[3]
					}
					uni.navigateTo({
						url: '/pages/home/child/equipment/device?data=' + JSON.stringify(data),
					});
				}
			} else {
				uni.showModal({
					content: '二维码内容：' + res.result,
					showCancel: false,
				});
			}
		},
		fail(e) {
			return;
			uni.showToast({
				title: '扫码错误：' + JSON.stringify(e),
				duration: 2000,
			});
		},
	});
}
/**
 * 获取二维码结果
 */
export function getScanCode() {
	let _this = this;
	return new Promise((resolve,reject) => {
		uni.scanCode({
			success: function(res) {
				let code = [''];
				try {
					code = res.result.split('-')
				} catch (e) {}
				if (code[0] == 'SB') {
					if (code[1] != _data.localData('obscode')) {
						uni.showModal({
							content: '请切换到对应水厂扫码'
						})
					} else {
						let data = {
							obscode: code[1],
							device: code[2],
							devicecode: code[3]
						}
						resolve(data)
					}
				} else {
					uni.showModal({
						content: '请扫描设备二维码',
						showCancel: false,
					});
				}
			},
			fail(e) {
				reject()
				return;
				uni.showToast({
					title: '扫码错误：' + JSON.stringify(e),
					duration: 2000,
				});
			},
		});
	})
}
/**
 * 获取地址栏参数
 * @param {Object} url  地址
 * @param {Object} name  参数名
 * return  参数值
 */
function getQueryString(url, name) {
	let index = url.indexOf('?');
	let params = '&' + url.substring(index + 1);
	let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	let r = params.substr(1).match(reg);
	if (r != null) return unescape(r[2]);
	return null;
}

// 获取任意两个日期中的所有日期
export function enumerateDaysBetweenDates(startDate, endDate, type = 'YYYY-MM-DD') {
	let daysList = [];
	const start = moment(startDate);
	const end = moment(endDate);
	const day = end.diff(start, "days");
	daysList.push(start.format(type));
	for (let i = 1; i <= day; i++) {
	  daysList.push(start.add(1, "days").format(type));
	}
	return daysList;
}

//判断指定日期是否在两个日期之间
export function isDuringDate(startDate,endDate,date) {
	return new Date(date) >= new Date(startDate) && new Date(date) <= new Date(endDate)
}